package com.xbongbong.sys.model.impl;

import com.xbongbong.sys.domain.dao.CodeRelationDao;
import com.xbongbong.sys.domain.entity.CodeRelationEntity;
import com.xbongbong.sys.model.CodeRelationModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 连接器code关系
 * 创建时间 2021/6/24 1:45 PM
 * 修改时间 2021/6/24 1:45 PM
 * @author chy
 */
@Service("codeRelationModel")
public class CodeRelationModelImpl implements CodeRelationModel {

    @Resource
    private CodeRelationDao codeRelationDao;

    @Override
    public Integer insert(CodeRelationEntity entity) {
        return codeRelationDao.insert(entity);
    }

    @Override
    public Integer update(CodeRelationEntity entity) {
        return codeRelationDao.update(entity);
    }

    @Override
    public CodeRelationEntity getEntityByCode(String corpid, Integer businessType, String code) {
        Map<String, Object> param = new HashMap<>();
        param.put("corpid", corpid);
        param.put("code", code);
        param.put("businessType", businessType);
        param.put("del", 0);
        List<CodeRelationEntity> list = findEntitys(param);
        return list.isEmpty() ? null : list.get(0);
    }

    @Override
    public List<CodeRelationEntity> findEntitys(Map<String, Object> param) {
        return codeRelationDao.findEntitys(param);
    }

    @Override
    public void insertBatch(List<CodeRelationEntity> list) {
        codeRelationDao.insertBatch(list);
    }

    @Override
    public void deleteBatch(String corpid, Integer businessType, String thirdPartyCode, List<String> xbbCodeIn) {
        codeRelationDao.deleteBatch(corpid, businessType, thirdPartyCode, xbbCodeIn);
    }
}
